﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NhanAi.DAO;
using NhanAi.Entity;
namespace NhanAi.Public
{
    public partial class Search : PublicBasePage
    {

        Taxonomy taxonomy;
        List<NhanAi.Entity.Taxonomy> taxonomies;
        List<Post> posts;
        public Taxonomy Taxonomy { get { return taxonomy; } }
        public List<NhanAi.Entity.Taxonomy> Taxonomies { get { return taxonomies; } }
        public List<Post> Posts { get { return posts; } }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "GET")
            {
                PostDao dao = new PostDao();
                int total = 0;
                string searchString = Request["searchString"] == null ? "" : Request["searchString"];

                int page = Home.Utils.TypeWrapper.GetInt32(Request["page"]);
                posts = dao.ReadMany(20, page, CurrentLanguageCode, "post", "%" + searchString + "%", false, -1, NhanAi.App_Code.NAConstants.POST_STA_POST, null, null, out total);
                paging.PageNumber = page;
                paging.TotalItemCount = total;
            }
            paging.PageSize = 20;

        }
    }
}